import { type JwtPayload } from 'jsonwebtoken';

/**
 * Represents minimal user identity.
 */
export interface UserBasicIdentity {
  id: string;
  username: string;
}

/**
 * Extends basic identity with account and device info.
 */
export interface UserIdentity extends UserBasicIdentity {
  accountGroupId: string;
  deviceId?: string;
}

/**
 * Base token claims (similar to BaseClaims in Go).
 * Contains standard JWT fields + user identity.
 */
export interface BaseClaims extends JwtPayload, UserIdentity {}

/**
 * Extended claims for access token (contains roles).
 */
export interface MyClaims extends BaseClaims {
  roles: string[];
}

/**
 * Role details for client representation.
 */
export interface FullRole {
  id: string;
  authority: string;
  title: string;
}

/**
 * Represents complete user info returned to client.
 */
export interface MyUserDetails extends UserIdentity {
  fullName: string;
  avatarUrl: string;
  isAccountGroupCreator: boolean;
  roles: string[];
  fullRoles: FullRole[];
  bearer: string;
  accessToken: string;
  generatedAt: string;
  expiredAt: string;
  refreshToken: string;
  expiresIn: number;
}

export class ParsedToken {
  claims: MyClaims | null = null;
  valid: boolean = false;
  expired: boolean = false;
  token: string = '';
}
